<?php
// Neu ung dung hien thoi khong phai la ISA-USER, thi khoi tao cac bien sesion de luu danh sach cac modul, function ma NSD duoc ban quyen thuc hien
if ($_ISA_APP_CODE !='ISA-USER'){
	// Khoi tao bien session $_SESSION['arr_all_staff'] de luu thong tin ca nhan cua tat ca staff
	if(!isset($_SESSION['arr_all_staff']) Or (isset($_SESSION['arr_all_staff']) And sizeof($_SESSION['arr_all_staff'])==0)){
		$p_arr_items = array();
		$p_level1_tag_name = "staff";
		$p_level2_tag_name_list="id,name,code,unit_id,position_code,position_name,position_group_code,address,email,tel,order";
		$p_delimitor = ",";
		_get_personal_info_of_all_staff();
		$_SESSION['arr_all_staff'] = $p_arr_items;
		unset($p_arr_items);
	}
	// Khoi tao bien session $_SESSION['arr_all_enduser'] de luu thong tin ca nhan cua tat ca NSD trong ung dung
	if(!isset($_SESSION['arr_all_enduser']) Or (isset($_SESSION['arr_all_enduser']) And $_SESSION['arr_all_enduser']=="")){
		$p_arr_items = array();
		$p_level1_tag_name = "staff";
		$p_level2_tag_name_list="id,name,code,unit_id,position_code,position_name,address,email,tel,order";
		$p_delimitor = ",";
		_get_personal_info_of_all_enduser($_ISA_APP_CODE);
		$_SESSION['arr_all_enduser'] = $p_arr_items;
		unset($p_arr_items);
	}
	// Khoi tao bien session $_SESSION['arr_all_unit'] de luu thong tin ca nhan cua tat ca unit
	if(!isset($_SESSION['arr_all_unit']) Or (isset($_SESSION['arr_all_unit']) And $_SESSION['arr_all_unit']=="")){
		$p_arr_items = array();
		$p_level1_tag_name = "unit";
		$p_level2_tag_name_list="id,parent_id,name,code,address,email,tel,order";
		$p_delimitor = ",";
		_get_detail_info_of_all_unit();
		$_SESSION['arr_all_unit'] = $p_arr_items;
		unset($p_arr_items);
	}
	// Lay danh sach modul cong cong va khoi tao bien session
	// Chu y: PHAI DOI TEN onegate_public_modul_list THANH  xxxxx_public_modul_list (trong do xxxxx la ma cua appilaction - bo chu isa di)
	if (!isset($_SESSION['onegate_public_modul_list']) Or (isset($_SESSION['onegate_public_modul_list']) And $_SESSION['onegate_public_modul_list']=="")){
		$parameters = array('p_app_code'=>$_ISA_APP_CODE);
		$obj_client = new soapclient(_CONST_ISA_USER_WEBSERVICE_URL);
		$str_return = $obj_client->call('get_all_public_modul', $parameters);
		$_SESSION['onegate_public_modul_list'] = $str_return;
		if (_CONST_WRITE_LOG==1){
			_write_log_file($_ISA_LOGFILE_URL_PATH,"Goi ham get_all_public_modul(). Ket qua:".$str_return);			
		}
		if ($_SESSION['onegate_public_modul_list'] =='') $_SESSION['onegate_public_modul_list'] = "$";
	}
	// Lay danh sach modul da duoc ban quyen truy nhap cho nguoi dang nhap
	// Chu y: PHAI DOI TEN onegate_granted_modul_list THANH  xxxxx_granted_modul_list (trong do xxxxx la ma cua appilaction - bo chu isa di)
	if (!isset($_SESSION['onegate_granted_modul_list']) Or (isset($_SESSION['onegate_granted_modul_list']) And $_SESSION['onegate_granted_modul_list']=="")){
		$parameters = array('p_app_code'=>$_ISA_APP_CODE, 'p_staff_id'=>$_SESSION['staff_id']);
		$obj_client = new soapclient(_CONST_ISA_USER_WEBSERVICE_URL);
		$str_return = $obj_client->call('get_all_modul_granted_for_user', $parameters);
		$_SESSION['onegate_granted_modul_list'] = $str_return;
		if (_CONST_WRITE_LOG==1){
			_write_log_file($_ISA_LOGFILE_URL_PATH,"Goi ham get_all_modul_granted_for_user(). Ket qua:".$str_return);			
		}
		if ($_SESSION['onegate_granted_modul_list'] =='') $_SESSION['onegate_granted_modul_list'] = "$";
	}
	// Lay danh sach function cong cong va khoi tao bien session
	// Chu y: PHAI DOI TEN onegate_public_function_list THANH  xxxxx_public_function_list (trong do xxxxx la ma cua appilaction - bo chu isa di)
	if (!isset($_SESSION['onegate_public_function_list']) Or (isset($_SESSION['onegate_public_function_list']) And $_SESSION['onegate_public_function_list']=="")){
		$parameters = array('p_app_code'=>$_ISA_APP_CODE);
		$obj_client = new soapclient(_CONST_ISA_USER_WEBSERVICE_URL);
		$str_return = $obj_client->call('get_all_public_function', $parameters);
		$_SESSION['onegate_public_function_list'] = $str_return;
		if (_CONST_WRITE_LOG==1){
			_write_log_file($_ISA_LOGFILE_URL_PATH,"Goi ham get_all_public_function(). Ket qua:".$str_return);			
		}
		if ($_SESSION['onegate_public_function_list'] =='') $_SESSION['onegate_public_function_list'] = "$";
	}
	// Lay danh sach function da duoc ban quyen truy nhap cho nguoi dang nhap
	// Chu y: PHAI DOI TEN onegate_granted_function_list THANH  xxxxx_granted_function_list (trong do xxxxx la ma cua appilaction - bo chu isa di)
	if (!isset($_SESSION['onegate_granted_function_list']) Or (isset($_SESSION['onegate_granted_function_list']) And $_SESSION['onegate_granted_function_list']=="")){
		$parameters = array('p_app_code'=>$_ISA_APP_CODE, 'p_staff_id'=>$_SESSION['staff_id']);
		$obj_client = new soapclient(_CONST_ISA_USER_WEBSERVICE_URL);
		$str_return = $obj_client->call('get_all_function_granted_for_user', $parameters);
		$_SESSION['onegate_granted_function_list'] = $str_return;
		if (_CONST_WRITE_LOG==1){
			_write_log_file($_ISA_LOGFILE_URL_PATH,"Goi ham get_all_function_granted_for_user(). Ket qua:".$str_return);			
		}	
		if ($_SESSION['onegate_granted_function_list'] =='') $_SESSION['onegate_granted_function_list'] = "$";
	}
	// Lay danh sach cac nhom (group of end-user) cua isa-onegate
	// Chu y: PHAI DOI TEN onegate_arr_all_group THANH  xxxxx_arr_all_group (trong do xxxxx la ma cua appilaction - bo chu isa di)
	if (!isset($_SESSION['onegate_arr_all_group']) Or (isset($_SESSION['onegate_arr_all_group']) And $_SESSION['onegate_arr_all_group']=="")){
		$p_arr_items = array();
		$p_level1_tag_name = "group";
		$p_level2_tag_name_list="id,name,code,order";
		$p_delimitor = ",";
		_get_all_group_of_application($_ISA_APP_CODE);
		$_SESSION['onegate_arr_all_group'] = $p_arr_items;
		unset($p_arr_items);
	}
	if (!isset($_SESSION['recordtype'])||is_null($_SESSION['recordtype'])){
	    include "record/record-lib/qry_all_recordtype_for_session.php";
		$_SESSION['recordtype'] = $arr_all_recordtype;
		//var_dump($arr_all_recordtype); exit;
	}
}
?>